<template>
	<view class="content">
		<button @click="addData()">添加一条数据</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		onLoad() {
			// wx.cloud.init({
			// 	env: 'spinachead-bottle-4e3ldb260b193a'
			// })
			// db = wx.cloud.database({
			// 	env: 'spinachead-bottle-4e3ldb260b193a'
			// })
		},
		onShow() {
			wx.cloud.callFunction({name: 'add'}).then(res => {
				console.log("这是云函数res", res)
			})
		},
		methods: {
			addData() {
				let db = wx.cloud.database({
					env: 'spinachead-bottle-4e3ldb260b193a'
				})
				db.collection('user').add({
					data: {
						avatar: 'https://jiaoguanyi008.oss-cn-shenzhen.aliyuncs.com/miniPro/images/imgs/saleBanner3.png',
						city_code: '4103',
						gender: 2,
						open_id: "ddc",
						province_code: 42,
						region: '广东省深圳市',
						username: "mia"
					},
					success: function(res) {
						console.log(res)
					},
					fail: function(err) {
						console.log(err)
					}
				})
			}
			
		}
	}
</script>

<style>
</style>